import { getDailySuperVoucher, getDeliveryFeeReduction, getHighRatingRecommendation, getMembersSpendDiscount } from "@/api/goods"

export const loadDailySuperVoucher = async (page = 1, pageSize = 3) => {
    try {
        // 添加延迟来模拟真实网络请求，让loading状态更明显
        await new Promise(resolve => setTimeout(resolve, 800))
        const res = await getDailySuperVoucher({ page, pageSize })
        // 提取实际的数组数据，处理嵌套结构
        const actualData = res.data?.data || res.data || res
        return { success: true, data: actualData }
    } catch (error) {
        console.error('DailySuperVoucher error:', error)
        return { success: false, data: error }
    }
}
export const loadDeliveryFeeReduction = async (page = 1, pageSize = 3) => {
    try {
        // 添加延迟来模拟真实网络请求，让loading状态更明显
        await new Promise(resolve => setTimeout(resolve, 800))
        const res = await getDeliveryFeeReduction({ page, pageSize })
        // 提取实际的数组数据，处理嵌套结构
        const actualData = res.data?.data || res.data || res
        return { success: true, data: actualData }
    } catch (error) {
        console.error('DeliveryFeeReduction error:', error)
        return { success: false, data: error }
    }
}
export const loadHighRatingRecommendation = async (page = 1, pageSize = 3) => {
    try {
        // 添加延迟来模拟真实网络请求，让loading状态更明显
        await new Promise(resolve => setTimeout(resolve, 800))
        const res = await getHighRatingRecommendation({ page, pageSize })
        // 提取实际的数组数据，处理嵌套结构
        const actualData = res.data?.data || res.data || res
        return { success: true, data: actualData }
    } catch (error) {
        console.error('HighRatingRecommendation error:', error)
        return { success: false, data: error }
    }
}
export const loadMembersSpendDiscount = async (page = 1, pageSize = 3) => {
    try {
        // 添加延迟来模拟真实网络请求，让loading状态更明显
        await new Promise(resolve => setTimeout(resolve, 800))
        const res = await getMembersSpendDiscount({ page, pageSize })
        // 提取实际的数组数据，处理嵌套结构
        const actualData = res.data?.data || res.data || res
        return { success: true, data: actualData }
    } catch (error) {
        console.error('MembersSpendDiscount error:', error)
        return { success: false, data: error }
    }
}
